/**
 * 电站列表
 */

function refresh() {
	initItem();
	listps();
}


var psids = param.psids;
var dataHand = new AjaxHandler();

/*mui(".mui-bar-tab").off('tap','a');
mui(".mui-bar-tab").on('tap','a',function(e){
	mui.back();
});*/
initItem();
function initItem(){
	$("nav a").removeClass("mui-active");
	$("nav a").find("img").each(function(){
		var newsrc = $(this).attr("src").replace("-hover","");
		$(this).attr("src",newsrc);
	});
    $("nav a").find("img[src*='"+param.sel+"']").attr("src","../img/"+param.sel+"-hover.png");
    $("nav a").find("img[src*='"+param.sel+"']").closest("a").addClass("mui-active");
}
$(listps);
function listps(){
	$.proAjax({
		url: "/mobile/listps",
		data: { psids:psids },
		success: function (data) {
			dataHand.arrayAddToHtml("psmodel",data,"psothers",function(elm,datas){
				elm.find("a").off("click");
				elm.find("#patrols").text(datas.patrol);
				if(!datas.patrol){
					elm.find("#patrols").remove();
				}
				elm.find("#defects").text(datas.defect);
				if(!datas.defect){
					elm.find("#defects").remove();
				}
				elm.find("#erroreqs").text(datas.erroreq);
				if(!datas.erroreq){
					elm.find("#erroreqs").remove();
				}
				(function(da,m){
					elm.find("a").on("tap",function(e){
						e.preventDefault();
						var navsel = param.navsel;
				    	if(navsel == "defect" || navsel == "QXD") {
				    		router.href("./defectQXD.html",da);
				    	}else if(navsel == "yuebao"){
				    		router.href("./reportGL.html?datesel=month",da);
				    	}else if(navsel == "yichang"){
				    		router.href("./deviceGJ.html",da);
				    	}else if(navsel == "xunshi" || navsel == "XSDJ"){
				    		router.href("./patrolDJ.html",da);
				    	}else if(navsel == "nianbao"){
				    		router.href("./reportGL.html?datesel=year",da);
				    	}else if(navsel == "tongxun"){
				    		router.href("./tongxunEdit.html",da);
				    	}
					})
				}(datas.params,elm.find("a")));
			});
		}
	},true);
}
